package router

import (
	"github.com/gin-gonic/gin"
	"ucenter/app/controller"
	"ucenter/app/middlewares"
)

func GetRouter() *gin.Engine {
	router := gin.Default()
	//此处加中间件
	//访问日志 todo
	//router.Use()
	//统一参数返回 todo
	//router.Use()
	v1 := router.Group("/v1")
	{
		v1.POST("/register", controller.Register)
		v1.POST("/login", controller.Login)
		v1.POST("/send_sms", controller.SendSMSCode)
		v1.POST("/bind", controller.Bind)
	}
	//此处写内部接口
	internal := router.Group("/internal")
	{
		//todo 加密或签名
		internal.Use(middlewares.AuthInternal)
		//操作用户积分额度
		internal.POST("/do_balance", controller.Balance)
		internal.POST("/get_balance", controller.GetBalance)
		internal.POST("/payment_notify", controller.PayNotify)
	}
	//此处写已登录用户接口
	auth := router.Group("/auth")
	{
		//登录token校验中间件
		auth.Use(middlewares.AuthLogin)
		//接口
		auth.GET("/user_info", controller.GetUserInfo)
		auth.POST("/user_balance", controller.GetUserBalance)
		auth.POST("/pay", controller.PreOrder)
		auth.GET("/rummy", controller.RummyNode)
		auth.GET("/user/:uid", controller.GetSimpleUserInfo)
		auth.GET("/batch/:uid", controller.BatchGetSimpleUserInfo)
		auth.POST("/update", controller.UpdateUserInfo)
		auth.GET("/referrer", controller.ReferrerUrl)
	}
	return router
}
